import request from '../utils/request'

export function fetchNews({ page, pageSize }) {
  return request(`/api/fetch_news?_page=${page}&_limit=${pageSize}`);
}

export function getUsers(nextOpenid) {
  console.log(nextOpenid)
  return request(`/api/get_users?_next_openid=${nextOpenid}`);
}

export function getUserInfoList(openidList) {
  const list = openidList.map(item => { return {openid: item, lang: 'zh_CN'}})
  return request(`/api/get_user_info_list`, {
    method: 'POST',
    body: JSON.stringify(list),
  });
}

export function fetchNewsByMediaId(mediaIdArr) {
  return request(`/api/fetch_news_by_media_id`, {
    method: 'POST',
    body: JSON.stringify(mediaIdArr),
  });
}

export function sendCustomMsg(payload) {
  return request(`/api/send_custom_msg`, {
    method: 'POST',
    body: JSON.stringify(payload),
  });
}
